import { getServerSession } from "next-auth"; import { authOptions } from "../../api/auth/[...nextauth]"; import Image from "next/image"; import Link from "next/link"; import Head from "next/head"; import { useEffect, useState } from "react"; import { getUser } from "@/prisma/user"; import { NewNavbar } from "@/components/shared/NavBar"; import { toast } from "sonner"; export default function MyList({ media, sessions, user, time, userSettings }) { const [listFilter, setListFilter] = useState("all"); const [visible, setVisible] = useState(false); const [useCustomList, setUseCustomList] = useState(true); useEffect(() => { if (userSettings) { localStorage.setItem("customList", userSettings.CustomLists); setUseCustomList(userSettings.CustomLists); } }, [userSettings]); // Function to handle checkbox state changes const handleCheckboxChange = async () => { setUseCustomList(!useCustomList); // Toggle the checkbox state try { const res = await fetch("/api/user/profile", { method: "PUT", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ name: sessions?.user?.name, settings: { CustomLists: !useCustomList, }, }), }); const data = await res.json(); if (data) { toast.success(`Custom List is now ${!useCustomList ? "on" : "off"}`); } localStorage.setItem("customList", !useCustomList); } catch (error) { console.error(error); } }; const filterMedia = (status) => { if (status === "all") { return media; } return media.filter((m) => m.name === status); }; return ( <>
| Title | Score | Progress |
|---|---|---|
|
{item.media.status === "RELEASING" ? (
) : item.media.status === "NOT_YET_RELEASED" ? (
) : (
)}
|
{item.score === 0 ? null : item.score} | {item.progress === item.media.episodes ? item.progress : item.media.episodes === null ? item.progress : `${item.progress}/${item.media.episodes}`} |
Oops!
Looks like you haven't watch anything yet.
Oops!
It looks like this user haven't watch anything
yet.
{formattedDate}
; } function convertMinutesToDays(minutes) { const hours = minutes / 60; const days = hours / 24; if (days >= 1) { return days % 1 === 0 ? { days: `${parseInt(days)}` } : { days: `${days.toFixed(1)}` }; } else { return hours % 1 === 0 ? { hours: `${parseInt(hours)}` } : { hours: `${hours.toFixed(1)}` }; } }